package com.gr100.biz.app.mvc;

import com.gr100.biz.api.user.UserService;
import com.gr100.biz.kit.StrKit;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * Created by YFsoft on 16/3/14.
 */

@Controller
public class UserController extends ApiController{
    UserService _userService = new UserService();

    @ResponseBody
    @RequestMapping(value= "v1.0/user/signin",method= RequestMethod.POST)
    public Map signin(@RequestParam Map args){
        String login_name = StrKit.getStringValue(args,"login_name");
        String login_pass = StrKit.getStringValue(args,"login_pass");
        String type = StrKit.getStringValue(args,"type");
        String unionID = StrKit.getStringValue(args,"unionID");
        Map<String,Object> map = _userService.signin(type,login_name,login_pass,unionID);
        return parseResult(map);
    }

    @ResponseBody
    @RequestMapping(value= "v1.0/user/signup",method= RequestMethod.POST)
    public Map signup(@RequestParam Map args){
        String login_name = StrKit.getStringValue(args,"login_name");
        String login_pass = StrKit.getStringValue(args,"login_pass");
        String type = StrKit.getStringValue(args,"type");
        String unionID = StrKit.getStringValue(args,"unionID");
        Map<String,Object> map = _userService.signup(type, login_name, login_pass, login_pass,unionID);
        return parseResult(map);
    }
}
